package cn.colat.micse.common.pojo.qo;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.Data;
import lombok.EqualsAndHashCode;

import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;


@Data
@EqualsAndHashCode(callSuper = true)
public class PageQO extends BaseQO {

    @NotNull(message = "页码不能为空")
    @Min(value = 1, message = "页码最小为1")
    private Integer page;

    @NotNull(message = "分页大小不能为空")
    @Min(value = 1, message = "分页大小最小为1")
    private Integer pageSize;

    public PageQO getPageObject() {
        return this;
    }

    public Page<?> page() {
        Page<?> page = new Page<>();
        page.setCurrent(Long.parseLong(String.valueOf(page)));
        page.setSize(Long.valueOf(pageSize));
        return page;
    }
}
